import { sourcesMap, columnsMap, searchMap } from './table-sources';

export default function ListDecorator(target) {
  return class extends target {
    sources = sourcesMap.get(this.name);
    columns = this.sources.columns.map(item => this.handleColumns && this.handleColumns.has(item) ? this.handleColumns.get(item)(columnsMap.get(item)) : columnsMap.get(item));
    searchForm = this.sources.searchForm.map(item => this.handleSearchForm && this.handleSearchForm.has(item) ? this.handleSearchForm.get(item)(searchMap.get(item)) : searchMap.get(item));
    service = (params, id) => {
      return this.sources.service(params, id);
    };
  };
}
